<script type="text/javascript" src="/web/static/public/js/jquery.js"></script>
{js href="/web/static/public/layer/layer.js" /}
<link rel="stylesheet" type="text/css" href="http://cache.amap.com/lbs/static/main1119.css"/>
<script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
<script type="text/javascript" src='//webapi.amap.com/maps?v=1.3&key=897c37791dedfb7693f32913be501911&plugin=AMap.Riding'></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<!-- UI组件库 1.0 -->
<script src="//webapi.amap.com/ui/1.0/main.js"></script>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<div id="container"></div>
<style>
    .line{
        margin: 10px;
    }
    .amap-marker-label {
        font-size: 13px;
        border: 1px solid orange;
        background: #fff;
        border-radius: 10px 0 0 0;
        color: #690441;
    }
	.amap-marker .marker-route {
		position: absolute;
		width: 40px;
		height: 44px;
		color: #e90000;
		background: url(http://webapi.amap.com/theme/v1.3/images/newpc/poi-1.png) no-repeat;
		cursor: pointer;
	}
	.amap-marker .marker-marker-bus-from {
		background-position: -334px -180px;
	}
	.amap-marker .marker-marker-bus-to {
		background-position: -334px -135px;
	}
</style>
<script>
    layer.config({
        extend: 'extend/layer.ext.js'
    });

    var map = null;
    var infoWindow = null;

    //标记
    function addMarker(lng,lat,type,content,title) {
        if(type){
            icon = '/web/marker.png';
        }else{
            icon = '/express.png';
        }
        marker = new AMap.Marker({
            icon: icon,
            label: {
                content: title,
                offset: new AMap.Pixel(27, 25)
            },
            position: [lng,lat]
        });
        marker.setMap(map);

        infoWindow = new AMap.InfoWindow({
            offset: new AMap.Pixel(0, -20),
            content: content  //使用默认信息窗体框样式，显示信息内容
        });

        marker.content = content;
        marker.on('click', markerClick);
        marker.emit('click', {target: marker});

    }

    function markerClick(e) {
        infoWindow.setContent(e.target.content);
        infoWindow.open(map, e.target.getPosition());
    }

    map = new AMap.Map('container', {
        resizeEnable: true,
        center: [{$center.lng},{$center.lat}],
        zoom: 16
    });
	//start
	var circle = new AMap.Circle({
        map: map,
        center: [{$seller_info.lng},{$seller_info.lat}],          //设置线覆盖物路径
		radius: 1500,
        strokeColor: "#33B166", //边框线颜色
        strokeOpacity: 0.6,       //边框线透明度
        strokeWeight: 1,        //边框线宽
		zIndex:9999,
        fillColor: "#33B166", //填充色
        fillOpacity: 0.35//填充透明度
    });
	var circle = new AMap.Circle({
        map: map,
        center: [{$center.lng},{$center.lat}],          //设置线覆盖物路径
		radius: 1500,
        strokeColor: "#3366FF", //边框线颜色
        strokeOpacity: 0.6,       //边框线透明度
        strokeWeight: 1,        //边框线宽
		zIndex:9999,
        fillColor: "#FFA500", //填充色
        fillOpacity: 0.35//填充透明度
    });
	var marker = new AMap.Marker({ //添加自定义点标记
        map: map,
        position: [{$seller_info.lng},{$seller_info.lat}], //商户坐标
        offset: new AMap.Pixel(-17, -42), //相对于基点的偏移位置
        draggable: true,  //是否可拖动
        content: '<div class="marker-route marker-marker-bus-from"></div>'   //自定义点标记覆盖物内容
    });
	marker.setAnimation('AMAP_ANIMATION_BOUNCE');
	var marker = new AMap.Marker({ //添加自定义点标记
        map: map,
        position: [{$center.lng},{$center.lat}], //用户坐标
        offset: new AMap.Pixel(-17, -42), //相对于基点的偏移位置
        draggable: true,  //是否可拖动
        content: '<div class="marker-route marker-marker-bus-to"></div>'   //自定义点标记覆盖物内容
    });
	marker.setAnimation('AMAP_ANIMATION_BOUNCE');
	 //骑行导航
    var riding = new AMap.Riding({
        map: map,
		hideMarkers:true,
    }); 
    //根据起终点坐标规划骑行路线
    riding.search([{$seller_info.lng},{$seller_info.lat}],[{$center.lng},{$center.lat}]);
	//end
    //addMarker('{$center.lng}','{$center.lat}',true,'订单位置');

    var express_string = '{$express_str}';
    var express_array = express_string.split('&');

    for(var i in express_array){
        addMarker(express_array[i].split(',')[0],express_array[i].split(',')[1],false,'<div><div class="line">'+express_array[i].split(',')[2]+'</div> <div class="line">当前订单量：'+express_array[i].split(',')[3]+'</div> <!--<div style="background: red;width: 5px;height: 5px;border-radius: 50%;float: right"></div>--> </div> <div class="line"> <button onclick=give_you("'+express_array[i].split(',')[4]+'")>派给他</button> </div>',express_array[i].split(',')[2]);
    }

    function give_you(id) {
        var order_id = '{$order_id}';
        if(!confirm('确定要将订单分配给此配送员吗？')){
            return;
        }
        $.post('__URL__/dispatch',{order_id:order_id,'uid':id},function (json) {
            layer.msg(json.msg);
            setTimeout(function () {
                if(json.state == 1){
                    location.reload();
                }
            },700)
        })
    }

</script>